//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by mac on 15/7/31.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate{
//      用户是否成功登陆标记
   //var userLogon = UserAccount.loadAccount() != nil
    var userLogon = false
    /// 访客视图
    var visitorView: VisitorLoginView?

    
    override func loadView() {
        userLogon ? super.loadView() :setupVisitorView()
    }
    
//    添加访客视图
    func setupVisitorView() {
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
        view = visitorView

        view.backgroundColor = UIColor(white: 0.93, alpha: 1.0)
        
//        添加导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
    }
/// 用户注册
    func visitorLoginViewWillRegister() {
        print("注册")
    }
    
/// 用户登录
    func visitorLoginViewWillLogin() {
        print("登陆")
        let nav = UINavigationController(rootViewController: OAuthViewController())
//        modal一个控制器
        presentViewController(nav, animated: true, completion: nil)
        
    }
   
    
}
